﻿Ext.util.DelayedTask = function (fn, scope, args) {
    var me = this,
        id,
        call = function () {
            clearInterval(id);
            id = null;
            fn.apply(scope, args || []);
        };


    this.delay = function (delay, newFn, newScope, newArgs) {
        me.cancel();
        fn = newFn || fn;
        scope = newScope || scope;
        args = newArgs || args;
        id = setInterval(call, delay);
    };


    this.cancel = function () {
        if (id) {
            clearInterval(id);
            id = null;
        }
    };
};